#include <bits/stdc++.h>

#define eb emplace_back
#define ep emplace
#define fi first
#define se second
#define in read<int>()
#define lin read<ll>()
#define rep(i, x, y) for(int i = (x); i <= (y); i++)
#define per(i, x, y) for(int i = (x); i >= (y); i--)

using namespace std;

using ll = long long;
using db = double;
using pii = pair < int, int >;
using vec = vector < int >;
using veg = vector < pii >;

template < typename T > T read() {
	T x = 0; bool f = 0; char ch = getchar();
	while(!isdigit(ch)) f |= ch == '-', ch = getchar();
	while(isdigit(ch)) x = x * 10 + (ch ^ 48), ch = getchar();
	return f ? -x : x;
}

template < typename T > void chkmax(T &x, const T &y) { x = x > y ? x : y; }
template < typename T > void chkmin(T &x, const T &y) { x = x < y ? x : y; }

const int N = 5e5 + 10;

int n, m, K, d;

struct node {
	ll v, mx, mn, res;
} val[N << 2];
ll tg[N << 2];

node operator + (node a, node b) {
	node c; c.v = a.v + b.v; c.res = min(a.res, b.res); c.mx = max(a.mx, b.mx); c.mn = min(a.mn, b.mn);
	chkmin(c.res, b.mn - a.mx); return c;
}

void pt(int o, ll v) { val[o].v += v; val[o].mx += v; val[o].mn += v, tg[o] += v; }
void pd(int o) { if(tg[o]) pt(o << 1, tg[o]), pt(o << 1 | 1, tg[o]), tg[o] = 0; }
void upd(int xl, int xr, ll v, int o = 1, int l = 0, int r = n - d) {
	if(xl == l && xr == r) return pt(o, -v); int mid = l + r >> 1; pd(o);
	if(xr <= mid) upd(xl, xr, v, o << 1, l, mid); else if(xl > mid) upd(xl, xr, v, o << 1 | 1, mid + 1, r);
	else upd(xl, mid, v, o << 1, l, mid), upd(mid + 1, xr, v, o << 1 | 1, mid + 1, r); val[o] = val[o << 1] + val[o << 1 | 1];
}
void build(int o = 1, int l = 0, int r = n - d) {
	if(l == r) return val[o].v = val[o].mx = val[o].mn = 1ll * l * K, val[o].res = 0, void(); int mid = l + r >> 1;
	build(o << 1, l, mid); build(o << 1 | 1, mid + 1, r); val[o] = val[o << 1] + val[o << 1 | 1]; 
}

int main() {
#ifndef ONLINE_JUDGE
	freopen("1.in", "r", stdin);
#endif
	n = in, m = in, K = in, d = in;
	build();
	while(m--) {
		int r = in, t = in; upd(r, n - d, t); puts(val[1].res + 1ll * K * d >= 0 ? "TAK" : "NIE");
	}
	return 0;
}
